<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/24
 * Time: 0:38
 */

namespace app\api\model;


use think\Model;

class Server extends Model
{
    public function lists($field , $map , $page = 1 , $pagesize = 10){
        $offset = ($page - 1) * $pagesize;
        $model = db("server");
        $list =  $model->field($field)->where($map)->limit($offset , $pagesize)->order("id desc")->select();
        $count = $model->count("id");
        return ["list" => $list ,"count" => $count];
    }

    public function add($data){
        return db("server")->insertGetId($data);
    }

    public function remove($id){
        $rows = db("Server")->delete(["id" => $id]);

        return $rows ;
    }

    public function info($id){
        return db("Server")->where(["id" => $id])->find();
    }
}